 

using System;
using System.Collections;

namespace Petaframe.Logging
{
	
	public class LogEntryCategoryFilter : LogEntryFilter 
	{
		
		private IList _categories = new ArrayList();
		
		private bool _allow = true;

		
		public bool Allow 
		{
			get { return _allow; }
			set { _allow = value; }
		}
		
		protected IList Categories 
		{
			get { return _categories; }
			set { _categories = value; }
		}
			
		
		protected LogEntryCategoryFilter() 
		{
		}
		
		public LogEntryCategoryFilter(bool allowFlag) : this()
		{
			Allow = allowFlag;
		}

		
		public void AddCategory(Object aCategory) 
		{
			Categories.Add(aCategory);
		}
		
		public void removeCategory(Object aCategory) 
		{
			Categories.Remove(aCategory);
		}
		
		protected override bool CanPass(LogEntry aLogEntry) 
		{
			bool hasCategory = Categories.Contains(aLogEntry.Category);
			return Allow ? hasCategory : ! hasCategory;
		}
	}
}
